#include <iostream>
#include <algorithm>
constexpr int MAXN = 100;
int n;
int v1[MAXN], v2[MAXN];
using namespace std;
int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> v1[i];
    for (int i = 0; i < n; i++)
        cin >> v2[i];
    sort(v1, v1 + n, less<int>());
    sort(v2, v2 + n, greater<int>());
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += v1[i] * v2[i];
    }
    cout << sum << endl;
}

